package com.example.performance.model;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.List;

/**
 * 测试场景模型
 * 表示一个完整的压测场景配置
 */
public class TestScenario {

    @JsonProperty("name")
    private String name; // 场景名称

    @JsonProperty("description")
    private String description; // 场景描述

    @JsonProperty("requests")
    private List<HttpRequest> requests = new ArrayList<>(); // HTTP请求列表

    @JsonProperty("executionMode")
    private ExecutionMode executionMode = ExecutionMode.SEQUENTIAL; // 执行模式，默认串行

    @JsonProperty("delayBetweenRequests")
    private long delayBetweenRequests = 0; // 请求间延迟时间（毫秒）

    @JsonProperty("repeatCount")
    private int repeatCount = 1; // 场景重复次数，默认1次

    @JsonProperty("enabled")
    private boolean enabled = true; // 是否启用此场景

    /**
     * 执行模式枚举
     */
    public enum ExecutionMode {
        @JsonProperty("sequential")
        SEQUENTIAL, // 串行执行
        @JsonProperty("parallel")
        PARALLEL // 并行执行
    }

    // 构造函数
    public TestScenario() {
    }

    public TestScenario(String name, String description) {
        this.name = name;
        this.description = description;
    }

    // Getter和Setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<HttpRequest> getRequests() {
        return requests;
    }

    public void setRequests(List<HttpRequest> requests) {
        this.requests = requests;
    }

    public ExecutionMode getExecutionMode() {
        return executionMode;
    }

    public void setExecutionMode(ExecutionMode executionMode) {
        this.executionMode = executionMode;
    }

    public long getDelayBetweenRequests() {
        return delayBetweenRequests;
    }

    public void setDelayBetweenRequests(long delayBetweenRequests) {
        this.delayBetweenRequests = delayBetweenRequests;
    }

    public int getRepeatCount() {
        return repeatCount;
    }

    public void setRepeatCount(int repeatCount) {
        this.repeatCount = repeatCount;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    /**
     * 添加HTTP请求到场景中
     * 
     * @param request HTTP请求对象
     */
    public void addRequest(HttpRequest request) {
        this.requests.add(request);
    }

    @Override
    public String toString() {
        return "TestScenario{" +
                "name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", requestCount=" + requests.size() +
                ", executionMode=" + executionMode +
                '}';
    }
}